/******************************************************************************
 *      Mestrado em Ciência da Computação - UFMS
 *		Redes de Computadores - Prof. Dr. Ronaldo Alves Ferreira
 *		Alunos: Geraldo Landre, Marcel Tolentino, Vinícius Bueno
 *****************************************************************************/
/* tcphowmuch.c.c - tcphowmuch */

#include "tcpfms.h"
#include "tcb.h"
#include "tcp.h"

/*------------------------------------------------------------------------
 *  tcphowmuch.c - compute how much data is available to send
 *------------------------------------------------------------------------
 */
int tcphowmuch(struct tcb *ptcb)
{
    int tosend;

    tosend = ptcb->tcb_suna + ptcb->tcb_sbcount - ptcb->tcb_snext;
    if (ptcb->tcb_code & TCPF_SYN)
        ++tosend;
    if (ptcb->tcb_flags & TCBF_SNDFIN)
        ++tosend;
    return tosend;
}
